package com.hsgene.product.exception;

import com.hsgene.common.util.exception.ErrorCode;

/**
 * @desc:
 * @author: fuxiang
 * @date: 2018/8/14 17:01
 */
public enum ProductErrorCode implements ErrorCode {

    /**
     * 套餐商品模块错误码定义
     */
    OPERATION_FAILED(30001, "operation_failed", "操作失败"),

    PRIMARY_KEY_CANNOT_BE_EMPTY(30002, "primary_key_cannot_be_empty", "主键不能为空"),

    OBJECT_IS_EMPTY(30003, "object_is_empty", "对象为空"),

    ALREADY_USED(30009, "already_used", "当前样本已被使用，不可删除"),
    PACKAGE_ALREADY_EXISTS(30011, "package_already_exists", "套餐已存在"),
    PARAMETER_CANNOT_BE_EMPTY(300012, "parameter_cannot_be_empty", "参数不能为空"),
    PACKAGE_HAS_BEEN_USED(300013, "package_has_been_used", "套餐已被使用无法修改"),
    THIS_PACKAGE_HAS_BEEN_MARKED(300014, "this_package_has_been_marked", "改套餐已被标记"),
    FAILED_TO_GET_AGENCY_SERVICE(300015, "failed_to_get_agency_service", "获取机构服务失败"),
    NUMBER_CANNOT_BE_EMPTY(30010, "number_cannot_be_empty", "编号不能为空"),
    GET_BANNER_IS_ERROR(30021, "Get_Banner_Is_Error", "获取首页banner(轮播)图片出错"),
    GET_IMAGES_IS_ERROR(30022, "Get_Images_Is_Error", "获取首页下面的9张图片出错"),
    GET_BANNER_IS_NULL(30023, "Get_Banner_Is_Null", "获取首页banner(轮播)图片数据为空"),
    GET_IMAGES_IS_NULL(30024, "Get_Images_Is_Null", "获取首页下面的9张图片数据为空"),
    THE_SORT_VALUE_ALREADY_EXISTS(30024, "the_sort_value_already_exists", "已存在该排序值"),
    THIS_CATEGORY_ALREADY_EXISTS(30025, "this_category_already_exists", "已存在该类目"),
    THE_PACKAGE_HAS_BEEN_USED_AND_CANNOT_BE_DELETED(30026, "the_package_has_been_used_and_cannot_be_deleted",
            "当前套餐已被使用，不可删除"),
    CANNOT_BE_DELETED_AFTER_BEING_USED(30027, "cannot_be_deleted_after_being_used", "已被使用不能删除"),

    GET_SHOPPING_CAR_COMMODITY_LIST_IS_ERROR(30028, "GET_SHOPPING_CAR_COMMODITY_LIST_IS_ERROR", "获取购物车商品列表数据出错"),
    COMMODITY_IDS_IS_NULL(30029, "COMMODITY_IDS_IS_NULL", "商品id数组为空"),
    GET_SHOPPING_CAR_COMMODITY_LIST_BY_IDS_IS_ERROR(30030, "GET_SHOPPING_CAR_COMMODITY_LIST_BY_IDS_IS_ERROR",
            "获取购物车商品列表数据出错"),
    GET_SHOPPING_CAR_COMMODITY_BALANCE_BY_IDS_IS_ERROR(30031, "GET_SHOPPING_CAR_COMMODITY_BALANCE_BY_IDS_IS_ERROR",
            "获取购物车商品结算信息出错"),
    EXISTED(30032, "EXISTED", "已存在"),
    ALREADY_ON_THE_SHELVES(30033, "already_on_the_shelves", "当前商品已经上架，请联系商城人员下架后再修改"),
    CAN_NOT_BE_DELETED(30034, "CAN_NOT_BE_DELETED", "当前商品已经上架，请联系商城人员下架后再删除"),

    COMMODITY_NOT_EXISTED(30035, "Error_Product_Commodity_Not_Existed", "商品套餐不存在"),

    COMMODITY_UPDATE_ONLINE(30036, "Error_Product_Commodity_Update_Online", "上架中的商品不允许修改"),

    COMMODITY_UPDTAE_USED(30037, "Error_Product_Commodity_Update_Used", "已被使用的商品不允许修改"),

    COMMODITY_CATEGORY_NOT_EXISTED(30038, "Error_Product_Commodity_Category_Not_Existed", "商品类目不存在"),

    COMMODITY_DELETE_ONLINE(30039, "Error_Product_Commodity_Delete_Online", "上架中的商品不允许删除"),

    COMMODITY_DELETE_USED(30040, "Error_Product_Commodity_Delete_Used", "已被使用的商品不允许删除"),
    GET_APPLETS_ORDER_PACKAGE_INFO_DTO_BY_IDS_IDS_IS_NULL(30100,
            "GET_APPLETS_ORDER_PACKAGE_INFO_DTO_BY_IDS_IDS_IS_NULL",
            "根据商品id数组获取小程序订单商品信息商品id数组为空"),
    GET_APPLETS_ORDER_PACKAGE_INFO_DTO_BY_IDS_IS_ERROR(30101, "GET_APPLETS_ORDER_PACKAGE_INFO_DTO_BY_IDS_IS_ERROR",
            "根据商品id数组获取小程序订单商品信息出错"),
    PACKAGE_INFO_IS_ERROR(30102, "PACKAGE_INFO_IS_ERROR", "该用户商品信息与传入商品信息不符"),
    ADD_SET_MEAL_TO_ELASTICSEARCH_IS_ERROR(30103, "ADD_SET_MEAL_TO_ELASTICSEARCH_IS_ERROR", "增加套餐信息到Elasticsearch出错"),
    UPDATE_SET_MEAL_FROM_ELASTICSEARCH_IS_ERROR(30104, "UPDATE_SET_MEAL_TO_ELASTICSEARCH_IS_ERROR",
            "修改Elasticsearch中套餐信息出错"),
    DELETE_SET_MEAL_FROM_ELASTICSEARCH_IS_ERROR(30105, "DELETE_SET_MEAL_TO_ELASTICSEARCH_IS_ERROR",
            "删除Elasticsearch中套餐信息出错"),
    SEARCH_SET_MEAL_FROM_ELASTICSEARCH_IS_ERROR(30106, "SEARCH_SET_MEAL_FROM_ELASTICSEARCH_IS_ERROR",
            "查询Elasticsearch中套餐信息出错"),
    GET_SHOPPING_CAR_COMMODITY_COUNT_BY_USER_ID_IS_ERROR(30107, "GET_SHOPPING_CAR_COMMODITY_COUNT_BY_USER_ID_IS_ERROR",
            "根据用户id获取购物车数量出错"),
    PLATFORM_IS_NULL(30108, "PLATFORM_IS_NULL", "平台类型为空"),
    BUY_TYPE_IS_NULL(30109, "BUY_TYPE_IS_NULL", "购买类型为空"),
    BUY_TYPE_IS_ERROR(30110, "BUY_TYPE_IS_ERROR", "购买类型有误"),
    COMMISSION_SORT_ORDER_IS_ERROR(30111, "COMMISSION_SORT_ORDER_IS_ERROR", "佣金排序规则有误"),
    NUMBER_SORT_ORDER_IS_ERROR(30112, "NUMBER_SORT_ORDER_IS_ERROR", "数量排序规则有误"),
    PRICE_SORT_ORDER_IS_ERROR(30113, "PRICE_SORT_ORDER_IS_ERROR", "价格排序规则有误"),
    USAGE_COUNT_SORT_ORDER_IS_ERROR(30114, "USAGE_COUNT_SORT_ORDER_IS_ERROR", "使用计数排序规则有误"),
    UPDATE_DATE_TIME_SORT_ORDER_IS_ERROR(30115, "UPDATE_DATE_TIME_SORT_ORDER_IS_ERROR", "更新时间排序规则有误"),
    MIN_PRICE_IS_NEGATIVE(30116, "MIN_PRICE_IS_NEGATIVE", "最低价格为负数"),
    MAX_PRICE_IS_NEGATIVE(30117, "MAX_PRICE_IS_NEGATIVE", "最高价格为负数"),
    MIN_PRICE_GREATER_THAN_MAX_PRICE(30118, "MIN_PRICE_GREATER_THAN_MAX_PRICE", "最低价格大于最高价格"),
    PACKAGE_ID_IS_NULL(30119, "PACKAGE_ID_IS_NULL", "套餐id为空"),
    SEARCH_BY_PACKAGE_ID_IS_ERROR(30120, "SEARCH_BY_PACKAGE_ID_IS_ERROR", "根据套餐id获取套餐出错"),
    INTEGRATION_IS_NOT_POSITIVE_INTEGER(30121, "INTEGRATION_IS_NOT_POSITIVE_INTEGER", "积分不是正整数"),
    EXISTING_TEMPLATE_CANNOT_BE_ADDED(30122, "EXISTING_TEMPLATE_CANNOT_BE_ADDED", "已存在模板，不能添加"),
    QUERY_SHOPPING_CAR_DISCOUNTS_IS_ERROR(30123, "QUERY_SHOPPING_CAR_DISCOUNTS_IS_ERROR", "查询购物车优惠券出错"),
    DISCOUNTS_PRICE_IS_POSITIVE_NUMBER(30124, "DISCOUNTS_PRICE_IS_POSITIVE_NUMBER", "优惠券价格只能是正数"),
    PURCHASE_AMOUNT_SORT_IS_ERROR(30125, "PURCHASE_AMOUNT_SORT_IS_ERROR", "购买数量排序有误"),
    SHOW_PRICE_SORT_IS_ERROR(30126, "SHOW_PRICE_SORT_IS_ERROR", "套餐价格排序有误"),
    UPDATE_DATE_TIME_SORT_IS_ERROR(30127, "UPDATE_DATE_TIME_SORT_IS_ERROR", "最后修改时间排序有误"),
    SAMPLE_SERVICE_CALL_FAILED(30128,"SAMPLE_SERVICE_CALL_FAILED","样本服务调用失败"),
    WRONG_EXPERIENCE_VALUE(30129,"WRONG_EXPERIENCE_VALUE","常规案列地服经验值加医生经验值必须等于佣金"),
    URGENT_NEED_WRONG_EXPERIENCE_VALUE(30130,"URGENT_NEED_WRONG_EXPERIENCE_VALUE","急需案列地服经验值加医生经验值必须等于佣金"),
    IS_SHOPPING_CAR_IS_ERROR(30131, "IS_SHOPPING_CAR_IS_ERROR", "是否从购物车购买参数有误"),
    SORT_COLUMN_IS_ERROR(30132, "SORT_COLUMN_IS_ERROR", "排序字段有误"),
    INSTITUTIONAL_NAME_HAS_DUPLICATE_VALUES(30124,"INSTITUTIONAL_NAME_HAS_DUPLICATE_VALUES","存在相同机构"),
    DISCOUNT_ID_IS_NOT_NULL(30125,"DISCOUNT_ID_IS_NOT_NULL","优惠券id不能为空"),
    DISCOUNT_IS_ERROR(30126,"DISCOUNT_IS_ERROR","优惠券有误，该订单价格不符合该优惠券条件");

    private final int code;

    private final String message;

    private final String description;

    ProductErrorCode(int code, String message, String description) {
        this.code = code;
        this.message = message;
        this.description = description;
    }

    public static ProductErrorCode getEnum(int code) {
        for (ProductErrorCode sampleErrorCode : values()) {
            if (sampleErrorCode.code == code) {
                return sampleErrorCode;
            }
        }
        throw new IllegalArgumentException("No element matches " + code);
    }

    @Override
    public int getCode() {
        return code;
    }

    @Override
    public String getMessage() {
        return message;
    }

    @Override
    public String getDescription() {
        return description;
    }
}
